package com.hfzy.ihk.web.aliyuncall.conf;

import com.hfzy.ihk.common.support.redis.RedisConfig;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Created by Administrator on 2018/1/16.
 *
 * @author wws
 */
@Configuration
@Import(RedisConfig.class)
public class MvcConfig implements WebMvcConfigurer {

    //freeswitch录音文件绝对路径
    @Value("${freeswitch.recordFilePath}")
    private String recordFilePath;

    //对外访问的url
    @Value("${freeswitch.recordFileUrl}")
    private String  recordFileUrl;
    /**
     * 为freeswitch录音文件添加映射
     * @param registry
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {

        registry.addResourceHandler(recordFileUrl+"**").addResourceLocations("file:"+recordFilePath);

    }
}
